export {}

// 泛型 -- 把可变类型以参数的形式传入

// 定义泛型 <T>
interface ResData<T> {
    code: number,
    msg: string,
    data: T
}

// 定义子类型
interface User {
    name: string,
    age: number,
}
interface Goods {
    id: number,
    goodsName: string,
}

let user: ResData<User> = {
    code: 200,
    msg: 'OK',
    data: {
        name: 'John',
        age: 34,
    }
}
console.log(user)

let goods: ResData<Goods> = {
    code: 200,
    msg: 'OK',
    data: {
        id: 123,
        goodsName: 'cs'
    }
}
console.log(goods)